ABC264 C - Matrix Reducing
提出
code: python
h1, w1 = list(map(int, input().split()))
h2, w2 = list(map(int, input().split()))
for bt in b:
t = bt.pop(0)
解答
code: python
import itertools
h1, w1 = list(map(int, input().split()))
h2, w2 = list(map(int, input().split()))
def check(tmpa):
for i in range(h2):
for j in range(w2):
return False
return True
# 使用する行・列を全探索
for hc in itertools.combinations(range(h1), h2):
for wc in itertools.combinations(range(w1), w2):
# 全探索した結果から新しい行列 a' を作る
tmpa = []
for h in hc:
row = []
for w in wc:
tmpa.append(row)
# b と一致するか
if check(tmpa):
print("Yes")
exit()
print("No")
メモ
提出
AC/WA
code: python
from collections import defaultdict
h1, w1 = map(int, input().split())
h2, w2 = map(int, input().split())
# print(a) 1, 2, 3, 4, 5], 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, [16, 17, 18, 19, 20 # print(b) 6, 8, 9], [16, 18, 19
av = []
for h2i in range(h2):
for w2i in range(w2):
flag = False
for h1i in range(h1):
for w1i in range(w1):
if ai == bi:
flag = True
av.append((h1i, w1i))
if not flag:
print("No")
exit()
# print(av)
# (1, 0), (1, 2), (1, 3), (3, 0), (3, 2), (3, 3) d = defaultdict(list)
for h1i, w1i in av:
dv = []
for di in d.values():
dv.append(di)
for i in range(len(dv) - 1):
print("No")
exit()
print("Yes")